//
//  AccordingToHeightLabel.swift
//  DataStructure
//
//  Created by kys-20 on 2019/8/27.
//  Copyright © 2019 kys-20. All rights reserved.
//
import Foundation
import UIKit

class AccordingToHeightLabel: UILabel {
    
    var numLabel: UILabel!
    var labe: UILabel!
    var heightInt: Int!
    
    init(frame: CGRect,heightInt: Int) {
        super.init(frame: frame)
        self.heightInt = heightInt
        labe = UILabel()
        labe.frame = CGRect(x: 0, y: 110 - heightInt, width: 20, height: heightInt)
        labe.backgroundColor = UIColor.purple
        labe.layer.masksToBounds = true
        labe.layer.borderColor = UIColor.blue.cgColor
        labe.layer.borderWidth = 0.5
        self.addSubview(labe)
        
        numLabel = UILabel()
        numLabel.frame = CGRect(x: 0, y: 110, width: 20, height: 20)
        numLabel.textAlignment = .center
        numLabel.font = UIFont.systemFont(ofSize: 12)
        numLabel.textColor = UIColor.blue
        numLabel.text = String(heightInt)
        self.addSubview(numLabel)
    }
    
    enum colorType {
        case highlighted
        case normal
        case disable
    }
    func changeColor(type:colorType){
        switch type {
        case .normal:
            labe.backgroundColor = UIColor.purple
            labe.layer.borderColor = UIColor.blue.cgColor
        case .highlighted:
            labe.backgroundColor = UIColor.orange
            labe.layer.borderColor = UIColor.purple.cgColor
        default:
            labe.backgroundColor = UIColor.gray
            labe.layer.borderColor = UIColor.clear.cgColor
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
